package com.zzyweb.rentalcarsys.utils;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @author zhiyi
 * @date 9/30/25
 **/
@Component
public class MetaDataHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        strictInsertFill(metaObject,"publishDate",LocalDateTime.class, LocalDateTime.now());
        strictInsertFill(metaObject,"updateDate",LocalDateTime.class, LocalDateTime.now());
        strictInsertFill(metaObject,"createDatetime",LocalDateTime.class, LocalDateTime.now());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        strictUpdateFill(metaObject,"updateDate",LocalDateTime.class, LocalDateTime.now());
    }
}
